package org.dandelion.core.remote
{
	import mx.messaging.ChannelSet;
	import mx.rpc.AbstractOperation;
	import mx.rpc.AsyncToken;
	import mx.rpc.remoting.Operation;
	import mx.rpc.remoting.RemoteObject;
	
	/**
	 * 远程访问代理类，继承自RemoteObject，实现IDandelionRemoteObject接口
	 * 获取单个操作，并访问远程服务，注册Responder
	 * */
	public class DandelionRemoteObject extends RemoteObject implements IDandelionRemoteObject
	{
		public function DandelionRemoteObject()
		{
			super();
		}
		
		/**
		 * 
		 * 获取单个操作，并访问远程服务，注册Responder
		 * */
		public function call(methodName:String, callback:Function, ...args):void
		{
			//得到此远程service的单个操作（函数）
			var method:AbstractOperation = this.getOperation(methodName);
			//设置参数
			method.arguments = args[0];
			//发出请求
			var token:AsyncToken = method.send();
			//附加IResponser
			var responser:DandelionResponder = new DandelionResponder(callback);
			token.addResponder(responser);
		}
		
		public function succinctLogout():AsyncToken{
			return this.channelSet.logout();
		}
		/***
		 * 同setCredentials
		 * */
		public function succinctSetCredentials(username:String,password:String):void{
			this.setCredentials(username,password);
		}
		/***
		 * 同setRemoteCredentials 
		 * */
		public function succinctSetRemoteCredentials(username:String,password:String):void{
			this.setRemoteCredentials(username,password);
		}
	}
}